﻿@{
    ViewBag.Title = "ReviewLow";
    Layout = "~/Views/Shared/_BasicLayout.cshtml";
}

<script type="text/javascript">
    $(function () {
        var height = $("#divTotal").height();
        var master = $("#master").height();
        var content = parseFloat(height) - parseFloat(master) - 30;
        $("#tbList").css("height", content);
    });
</script>
<script type="text/javascript">
    $(function () {
        $("#tbList").datagrid({
            url: '/Review/GetLowReviewList',
            loadMsg: '数据加载中请稍后……',
            fitColumns: false,
            pagination: true,
            rownumbers: true,
            queryParams: com.serializeSearchArray("form1"),
            idField: "ID",
            singleSelect: true,
            pageSize: 20,
            pageList: [20, 50, 100],
            striped: true,
            columns: [[{ field: 'ck', checkbox: true, width: 30 },
             { field: 'ID', title: 'ID ', align: "center", width: 30 },
             { field: 'DocCode', title: '单据编号 ', align: "center", width: 100 },
             {
                 field: 'DocId', title: '审批类型 ', align: "center", width: 120, editor: {
                     type: "combobox",
                     options: {
                         url: "/Review/GetReviewType",
                         valueField: 'value',
                         textField: 'text',
                         required: true
                     }
                 }, formatter: function (value, row, index) {
                     return row.DocName;
                 }
             },
              {
                  field: 'ModName', title: '所属模块 ', align: "center", width: 120, formatter: function (value, row, index) {
                      return com.getArrayText(StaticCombo.ModName, value);
                  }
              },
             {
                 field: 'RankName', title: '标示名称 ', align: "center", width: 120, editor: {
                     type: "validatebox",
                     options: {
                         required: true
                     }
                 }
             },
             {
                 field: 'Rank', title: '标识 ', align: "center", hidden: true, width: 100, editor: {
                     type: "combobox",
                     options: {
                         data: StaticCombo.level,
                         valueField: 'value',
                         textField: 'text',
                         //required: true
                     }
                 }, formatter: function (value, row, index) {
                     return com.getArrayText(StaticCombo.level, value);
                 }
             },
             {
                 field: 'RevGroup', title: '分组 ', align: "center", width: 100, editor: {
                     type: "combobox",
                     options: {
                         data: StaticCombo.level,
                         valueField: 'value',
                         textField: 'text',
                         required: true
                     }
                 }, formatter: function (value, row, index) {
                     return com.getArrayText(StaticCombo.level, value);
                 }
             }, { field: 'reviewer', title: '审批人 ', align: "center", },
             {
                 field: 'CanDelete', title: '能否删除 ', align: "center", width: 100, formatter: function (value, row, index) {
                     return com.getArrayText(StaticCombo.AuditCanDelete, value);
                 }, editor: {
                     type: "combobox",
                     options: {
                         data: StaticCombo.AuditCanDelete,
                         valueField: 'value',
                         textField: 'text',
                         required: true
                     }
                 }
             },
             { field: 'ManClerk', title: '维护人 ', align: "center", width: 100 },
             { field: 'FillDate', title: '填写日期 ', align: "center", width: 100 },
           {
               field: 'Note', title: '备注 ', align: "center", width: 150, editor: {
                   type: "validatebox",
                   options: {

                   }
               }
           }]], onAfterEdit: function (rowIndex, rowData, changes) {
               if (editAction == "add") {
                   com.ajax({
                       url: "/Review/AddLowReivew",
                       data: rowData,
                       success: function (data) {
                           com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                       }
                   });
               }
               if (editAction == "edit") {
                   com.ajax({
                       url: "/Review/EditLowReivew",
                       data: rowData,
                       success: function (data) {
                           com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); });
                       }
                   });
               }
               editRow = undefined;
           }, onCancelEdit: function (rowIndex, rowData) {
               $("#tbList").datagrid("rejectChanges");

           }
        });
    });
</script>

<script type="text/javascript">

    editRow = undefined;
    editAction = undefined;
    function funcSearch() {
        var para = com.serializeSearchArray("form1");
        $("#tbList").datagrid("load", para);

    }
    function funcAdd() {
        //添加时先判断是否有开启编辑的行，如果有则把开户编辑的那行结束编辑
        if (editRow != undefined) {

        }
        //添加时如果没有正在编辑的行，则在datagrid的第一行插入一行
        if (editRow == undefined) {
            $("#tbList").datagrid("insertRow", {
                index: 0, // index start with 0
                row: {

                }
            });
            //将新插入的那一行开户编辑状态
            $("#tbList").datagrid("beginEdit", 0);
            //给当前编辑的行赋值
            editRow = 0;
            editAction = "add";
        }
    }
    function funcEdit() {
        var row = $('#tbList').datagrid('getSelected');
        if (row) {
            if (editRow != undefined) {
            }
            else {
                var index = $("#tbList").datagrid('getRowIndex', row);
                //   var index = row.Id;
                $("#tbList").datagrid('beginEdit', index);
                editAction = "edit";
                editRow = index;
            }
        }
        else {
            com.message("information", "请选中一行");
        }
    }
    function funcRemove() {
        var date = new Date();
        $.messager.confirm('确认对话框', '您确定删除该权限吗？', function (r) {
            if (r) {
                var rowData = $("#tbList").datagrid("getSelected");
                if (rowData) {
                    com.ajax({
                        url: '/Logic/BD/ReviewBasicAjax.aspx?method=RemoveLowReivew&date=' + date,
                        data: { Id: rowData.ID },
                        success: function (data) {
                            com.message(data.state, data.msg, function () { $("#tbList").datagrid("reload"); })

                        }

                    });
                }
            }
        });
    }

    function funcSave() {
        $('#tbList').datagrid('endEdit', editRow);

    }
    function funcCancel() {
        $('#tbList').datagrid("cancelEdit", editRow);
        editRow = undefined;
        editAction = undefined;
    }
    function funcReload() {
        $("#form1").form("reset");
        var para = com.serializeSearchArray("form1");
        $("#tbList").datagrid("load", para);
    }
    function funcSelectPeo() {
        var row = $('#tbList').datagrid('getSelected');
        if (row) {
            $.extend(com.dialogObj, { title: "分配人员", width: 500, height: 300, href: "/BD/User/AssignComboPeoWindow" });
            $("#assignComboPeo").dialog(
               com.dialogObj
            );
            $(top.document).find("#hidId").val(row.ID);
            $(top.document).find("#hidAction").val("low");
        }
        else {
            com.message("information", "请选中一行");
        }
    }
</script>
<div id="divTotal" style="height: 100%; width: 100%">

    <div id="master" class="container_12" style="height: auto">
        <form id="form1">
            所属模块:
            <input id="ModName" name="ModName" data-cp="=" class="easyui-combobox" data-options="valueField:'value',textField:'text',data:StaticCombo.ModName,panelHeight:'auto',editable:false" />
                <input id="DocName" name="DocName" data-cp="=" class="easyui-textbox" data-options="prompt:'审批类型'" />
        </form>
    </div>
    <table id="tbList" title="部门审批信息表 " style="width: 100%"></table>

</div>
<div id="assignComboPeo">
</div>
